﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IAD2
{
    class Neuron : IComparable<Neuron>
    {
        protected int _dimension;
        public double Distance;
        protected int sleep = 0;
        public int dimension
        {
            get { return _dimension; }
            set { _dimension = value; }
        }

        public bool checkSleep()
        {
            if (sleep == 0)
                return false;
            sleep--;
            return true;
        }

        public void goSleep(int epoc)
        {
            sleep = epoc;
        }

        public Neuron Clone()
        {
            return (Neuron) this.MemberwiseClone();
        }
       

        protected List<double> _weights;
        public List<double> weights
        {
            get { return _weights; }
        }

        public double X
        {
            get { return _weights[0]; }
        }
        public double Y { 
            get{ return _weights[1];}
        }

        public Neuron(double X, double Y)
        {
            this._weights = new List<double>();
            this._weights.Add(X);
            this._weights.Add(Y);
            this._dimension = 2;
        }

        public double distance(Neuron other)
        {
            return Math.Sqrt(Math.Pow(this.X - other.X, 2) + Math.Pow(this.Y - other.Y, 2));
        }

        public int CompareTo(Neuron other)
        {
            if (this.Distance < other.Distance)
                return -1;
            else if (this.Distance == other.Distance)
                return 0;
            else
                return 1;
            
        }

        public void moveTo(Neuron other, double n)
        {
            for(int i = 0;i<this.weights.Count; i++){
                this._weights[i] += n*(other.weights[i]- this._weights[i]);
            }
        }

       

     




        
    }
}
